boolean first = true;
Polygon pol;
color temporal = color(20, 0, 0);
color permanent = color(0, 20, 0);
int w = 768;
int h = 1024;
int x0, y0;
color backgroundColor = color(255, 255, 255);

void setup() {
  background(backgroundColor);
  size(w, h);
}

void draw() {

  if (!first) {
    background(backgroundColor);
    pol.draw(permanent, false);
    stroke(temporal);
    line(x0, y0, mouseX, mouseY);
  }
}

void mouseClicked() {

  if (first) {
    background(backgroundColor);
    first = false;
    x0 = mouseX;
    y0 = mouseY;
    pol = new Polygon();
    pol.addPoint(new PVector(x0, y0));
  }
  else {

    x0 = mouseX;
    y0 = mouseY;
    pol.addPoint(new PVector(x0, y0));
    if (mouseButton == RIGHT) {
      //      background(backgroundColor);
      //      pol.translate(-50,-50);
      //      pol.rotate(0.5);
      pol.scale(0.5);
      pol.draw(permanent, true);
      //pol.fill(color(random(255), random(255), random(255)));
      first = true;
    }
  }
}

